package com.zh.note.huawei.onehundred.新员工座位安排系统;

/**
 * @Author: zhanghuan
 * @date: 2023/8/6 11:09
 * @description: create it
 */
public class Main {
    public static void main(String[] args) {
        // Scanner sc = new Scanner(System.in);
        // String input = sc.nextLine();
        String input = "1 1 0 1 2 1 0 1 1 1 1";
        String[] strs = input.split(" ");
        // 最大连续1的个数
        int maxCount = 0;
        // 左侧连续1的个数
        int leftCount = 0;
        // 右侧连续1的个数
        int rightCount = 0;
        for (int i = 0; i < strs.length; i++) {
            if (strs[i].equals("1")) {
                leftCount++;
            } else if (strs[i].equals("2")) {
                leftCount = 0;
            } else if (strs[i].equals("0")) {
                int j = i + 1;
                while (j < strs.length && strs[j].equals("1")) {
                    rightCount++;
                    j++;
                }
                maxCount = Math.max(maxCount, leftCount + rightCount);
                rightCount = 0;
                leftCount = 0;
            }
        }
        System.out.println(maxCount);

    }
}
